<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<?xml version="1.0" encoding="UTF-8" ?>
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title>jquery验证示例</title>
		<link rel="stylesheet" href="${pageContext.request.contextPath}/css/jquery.validate.css"
			type="text/css" media="screen" />
		<script src="${pageContext.request.contextPath}/js/jquery.js" type="text/javascript"
			language="javascript"></script>
		<script src="${pageContext.request.contextPath}/js/validate/jquery.validate.min.js"
			type="text/javascript"></script>
		<script src="${pageContext.request.contextPath}/js/validate/additional-methods.js"
			type="text/javascript"></script>
		<script src="${pageContext.request.contextPath}/js/validate/messages_cn.js"
			type="text/javascript"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery.metadata.js"></script>
<script type="text/javascript">
$(function(){
$.metadata.setType('attr','validate');
	$("#form").validate({
		submitHandler:function(form){
			if($('#allDay').attr('checked')){//checked取值
				$('#bizHour').val("00:00-23:59");
			}else if($.trim($('#bts').val()).length!=0){
				$('#bizHour').val($('#bts').val()+"-"+$('#bte').val());
			}
			
			
			form.submit();
		}
	});
	
	//动态添加规则
	$('#bizHour').rules('add',{bothRequired:["#bts","#bte"],timeCompare:["#bts","#bte"],messages:{bothRequired:"请输入开始时间和结束时间",timeCompare:"结束时间要大于开始时间"}});
	
	//单个元素验证
	$('#bts').blur(function(){
		$("#form").validate().element($('#bizHour'));
	});
	
	//所需设备全不选择时处理
			if($('input[name="needDevice"]:checked').length==0){
				$('#needDeviceDefault').attr('checked','checked');
			}
	
			//地区设置
			var area=$('#area').val();
			$('#areaId option[value="'+area+'"]').attr("selected","selected");//selected设置
			
			
			
			//所需设备设置
			var nd=$('#_needDevice').val();
			if(nd.length!=0){
				var ndA=nd.replace(/\s/g,"").split(",");
				for(var i=0;i<ndA.length;i++){
					$('input[name="needDevice"][value="'+ndA[i]+'"]').attr("checked","checked");
				}
			}
});
</script>
	</head>
	<body>
	</body>
</html>

